export default {
    Run() {
        setInterval(function(){
            $(".read-footer-pannel .left").remove()
            $("#js_swichH").remove()
            $("#js_ftAutoBtn").remove()
            $(".layui-layer:not(#layui-layer1)").remove()
            $("#layui-layer-shade1").remove()
            $("#js_payChapter").remove()
            $("#js_content").css("margin-top", "0")
        }, 20);

        var $ = window.$

        unsafeWindow.onload = function () {
            var comic_info = unsafeWindow.comicInfo;
            $("#readerContainer").css("height", "auto")
            $(".read-footer-pannel .inner .right").css("width","50%")

            $(".acgn-reader-chapter__item.no-chapter acgn-chapter__interact ").css("width", "100%")

            $("acgn-reader-chapter__item.no-chapter.acgn-chapter__interact").css("margin", "auto")
            $(".acgn-reader-chapter__item-box").each(function(){
                let chapter_id = $(this).attr("chapter-id")
                if (unsafeWindow.comicInfo.current_chapter.chapter_newid == chapter_id) {

                    $(this).find(".acgn-reader-chapter__item.loading").each(function(){
                        $(this).css("padding-bottom", "0px")
                        $(this).height("auto")
                        let index = $(this).attr("chapter-index");
                        var img_url = '//mhpic.' + unsafeWindow.comicInfo.current_chapter.chapter_domain + unsafeWindow.comicInfo.current_chapter.rule.replace('$$', index) + '-mht.low'
                        var html = '<div class="acgn-reader-chapter__swiper-box" style="width:100%" chapter-index="'+index+'" chapter-pid="3009">'+index+'<img src="'+img_url+'" style="width:100%"></div>'
                        if ($(document.body).width() >= 500) {
                            html = '<div class="acgn-reader-chapter__swiper-box" style="width:800px" chapter-index="'+index+'" chapter-pid="3009">'+index+'<img src="'+img_url+'" width="800"></div>'
                        }
                        $(this).html(html)
                    })

                } else {
                    $(this).remove()
                }
            })
            $("#js_pageNextBtn").on("click", function() {
                location.href = "https://www.manhuatai.com/"+unsafeWindow.comicInfo.comic_newid+"/"+unsafeWindow.comicInfo.next_chapter.chapter_newid+".html"
            })
            $("#js_pagePrevBtn").on("click", function() {
                location.href = "https://www.manhuatai.com/"+unsafeWindow.comicInfo.comic_newid+"/"+unsafeWindow.comicInfo.prev_chapter.chapter_newid+".html"
            })
        }
    }
}